﻿/*
 * Created by SharpDevelop.
 * User: cszhangyi
 * Date: 2016/4/9
 * Time: 18:35
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Collections.Generic;

using YMTSeller.Model;
using Newtonsoft.Json;

namespace YMTSeller
{
	/// <summary>
	/// Description of UserHandler.
	/// </summary>
	public class UserHandler
	{
		public UserHandler()
		{
		}
		
		public Dictionary<string, string> getUserInfo(string accessToken, string userId)
		{
			string url = "http://seller.app.ymatou.com/api/User/GetUserInfo";
			
			var model = new GetUserInfoRequestModel();
			
			model.AccessToken = accessToken;
			model.UserId = userId;
			model.AppName = "Seller";
			model.ClientType = 1;
			model.DeviceToken = "623ee5d7e41fd73213df948b9cafa924d4dedc32375a06af7c02eb37c03d5893";
			model.Guid = "5F58DCEF-D449-46FF-81EF-02B569B9B260";
			model.Wifi = 0;
			model.App = "seller";
			model.Os = "iPhone8,4";
			model.Sys = "9.3";
			model.Version = "2.5.1";
			
			string paramData = model.toString();
			
			var request = new YMTRequest();
			string val = request.get(url, paramData, System.Text.Encoding.GetEncoding("utf-8"));
			
			var responseModel = (GetUserInfoResponseModel) JsonConvert.DeserializeObject(val, typeof(GetUserInfoResponseModel));
			
			Dictionary<string, string> result = new Dictionary<string, string>();
			result.Add("Msg", responseModel.Msg);
			result.Add("Status", responseModel.Status.ToString());
			
			if (responseModel.Result != null)
			{
				result.Add("CountryId", responseModel.Result.CountryId.ToString());
				result.Add("NickName", responseModel.Result.NickName);
			}
			
			return result;
		}
	}
}
